package com.ciaojian.core.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ciaojian.core.model.UserTimesCard;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author oxiny
 */
public interface UserTimesCardMapper extends BaseMapper<UserTimesCard> {
    /**
     * 根据ID查询
     *
     * @param id /
     * @return /
     */
    UserTimesCard selectById(Integer id);

    /**
     * 根据ID查询
     *
     * @param userId /
     * @return /
     */
    List<UserTimesCard> getByUserId(Integer userId);

    /**
     * 查询用户次卡信息
     *
     * @param userId 用户ID
     * @param cardId 次卡ID
     * @return 用户次卡信息
     */
    @Select("SELECT * FROM d_user_times_card WHERE user_id = #{userId} AND card_id = #{cardId} ")
    UserTimesCard getByUserIdAndCardId(Integer userId, Integer cardId);

    /**
     * 根据用户ID和门店查询用户可用次卡
     *
     * @param userId       用户ID
     * @param storeId      门店ID
     * @param serviceTitle 服务标题
     * @return 用户可用次卡
     */
    List<UserTimesCard> listUserTimesCardUsable(@Param("userId") Integer userId,
                                                @Param("storeId") Integer storeId,
                                                @Param("serviceTitle") String serviceTitle);
}
